﻿@model IEnumerable<TravelWeb.Models.Customer>
@{
    ViewBag.Title = "Customer";
}
<h2>
    Customer</h2>
<table>
    <tr>
        <th>
            FirstName
        </th>
        <th>
            LastName
        </th>
        <th>
            Address
        </th>
        <th>
            City
        </th>
        <th>
            Nationality
        </th>
        <th>
            Phone
        </th>
        <th>
            Email
        </th>
        <th>
            Status
        </th>
        <th>
        </th>
    </tr>
    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.FirstName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.LastName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Address)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.City)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Nationality)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Phone)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Email)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Status)
            </td>
            <td>
                @if (User.IsInRole("Manager"))
                {
                    @Html.ActionLink("More details", "Details", new { id = item.CustomerId });
                    if (item.Status.Equals("Deactivated"))
                    {
                        @Html.ActionLink("Activate", "Activate", new { id = item.CustomerId });
                    }
                    if (item.Status.Equals("Activated"))
                    {
                        @Html.ActionLink("Deactivate", "Deactivate", new { id = item.CustomerId });
                    }
                }
                else if (User.IsInRole("User"))
                {
                    @Html.ActionLink("Edit", "Edit", new { id = item.CustomerId });
                    @Html.ActionLink("More details", "Details", new { id = item.CustomerId });
                }
            </td>
        </tr>
    }
</table>
